<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h2><c:out value="${person.firstName}"/> <c:out value="${person.lastName}"/></h2>
        <div class="colmask threecol">
            <div class="colmid">
                <div class="colleft">
                    <div class="col1" >
                        <h1>Admissions</h1>
                        <table class="default">
                            <tr>
                                <th>Season</th>
                                <th>From - to</th>
                                <th>Price [Kč]</th>
                                <th>Paid</th>
                                    <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                                    <th>Edit</th>
                                    <th>Remove</th>
                                    </c:if>
                            </tr>
                            <c:forEach  items="${admissions}" var="admission">
                                <tr>
                                    <td><c:out value="${admission.seasonName}"/></td>
                                    <td><c:out value="${admission.startDate}"/> <c:out value="${admission.endDate}"/></td>
                                    <td><c:out value="${admission.price}"/></td>
                                    <td><c:out value="${admission.timestamp}"/></td>
                                    <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                                        <td><a href="<c:url value="/admin/admission/edit?personId=${person.id}&seasonId=${admission.seasonId}" />"><img src="<c:url value="/resources/img/edit-icon.gif" />" width="16" height="16" alt="edit" /></a></td>
                                        <td><a href="<c:url value="/admin/admission/remove?personId=${person.id}&seasonId=${admission.seasonId}" />"><img src="<c:url value="/resources/img/remove-icon.gif" />" width="16" height="16" alt="remove" /></a></td>
                                            </c:if>
                                </tr>
                            </c:forEach>
                        </table>
                        <br/>
                        <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                            <div class="buttons">
                                <a href="<c:url value="/admin/admission/edit?seasonId=-1&personId=${person.id}" />" class="button add">Add a new admission record</a>
                            </div>
                        </c:if>
                    </div>
                    <div class="col2" >
                        <h1>Personal info</h1>
                        <table class="simple">
                            <tr>
                                <td>Date of birth</td>
                                <td><c:out value="${person.dateOfBirth}"/></td>
                            </tr>
                            <tr>
                                <td>Phone</td>
                                <td><c:out value="${person.phoneNumber}"/></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><c:out value="${person.email}"/></td>
                            </tr>
                            <tr>
                                <td>Address</td>
                                <td>
                                    <c:out value="${person.address.streetAndNumber}"/>
                                    <c:out value="${person.address.zipCode}"/> <c:out value="${person.address.city}"/>
                                    <c:out value="${person.address.country}"/>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div id="footer">
            <h1>Score</h1>
            <c:forEach  items="${seasons}" var="season">
                <h3><c:out value="${season.name}"/> (<c:out value="${season.startDate}"/> - <c:out value="${season.endDate}"/>)</h3>
                <table class="default">
                    <tr>
                        <th>Player 1 vs. Player 2</th>
                        <th>Date</th>
                        <th>Time</th>
                        <th>Final score</th>
                        <th></th>
                    </tr>
                    <c:forEach  items="${season.matchList}" var="match">
                        <tr>
                            <td><c:out value="${match.seasonName}"/></td>
                            <td><c:out value="${match.seasonStartDate}"/> <c:out value="${match.seasonEndDate}"/></td>
                            <td><c:out value="${match.dateAndTime}"/></td>
                            <td><c:out value="${match.finalScore}"/></td>
                            <td><a href="<c:url value="/admin/match/detail?id=${match.id}" />"><img src="<c:url value="/resources/img/detail-icon.png" />" width="16" height="16" alt="detail" /></a></td>
                        </tr>
                    </c:forEach>

                </table>
                <br/>
            </c:forEach>
        </div>
    </body>
</html>
